#ifndef TUNNEL_MAINWINDOW_H
#define TUNNEL_MAINWINDOW_H

#include <QtGui/QMainWindow>
#include <QtGui/QStandardItemModel>
#include <QtGui/QSystemTrayIcon>
#include "clientsocket.h"
#include "AddFriendDialog.h"
#include "friendinventationdialog.h"
#include "privatechatmanager.h"
#include <vector>

namespace Ui
{
    class Tunnel_MainWindow;
}

class Friendlist;
class ChatHandler;
class ClientSocket;
class Tunnel_MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    Tunnel_MainWindow(QWidget *parent = 0);
    ~Tunnel_MainWindow();

protected:
    void closeEvent(QCloseEvent *event);
    void changeEvent(QEvent *event);

private:
    Ui::Tunnel_MainWindow *ui;
    AddFriendDialog *addFriendDialog;
    std::vector<FriendInventationDialog *> friendRequests;
    PrivateChatManager *privateChatManager;

    Friendlist *m_friendlist;
    QStandardItemModel *friendlistItemModel;
    QMenu *friendlistMenu;

    ClientSocket *socket;

    QAction *restoreAction;
    QAction *quitAction;

    QSystemTrayIcon *sysTrayIcon;
    QMenu *sysTrayIconMenu;

    void showSysTrayMessage(const QString &message, int duration = 3, const QString &title = "", int icon = 0);

private slots:
    void on_errorMessage(const QString &error);
    void on_infoMessage(const QString &infoString);
    void on_pushButton_clicked();
    void on_sendMessageToFriend(const QString &friend_loginName, const QString &message);
    void on_lvFriends_doubleClicked(QModelIndex index);
    void sysTrayIconActivated(QSystemTrayIcon::ActivationReason reason);
    void on_friendGoesOnline(const QString &friend_loginName);
    void on_friendGoesOffline(const QString &friend_loginName);
    void on_pbLogout_clicked();
    void on_successfullyLoggedIn();
    void on_loginFailed(const QString &reason);
    void on_lvFriends_customContextMenuRequested(QPoint pos);
    void on_pbNewFriend_clicked();
    void on_lePasswort_returnPressed();
    void on_leBenutzername_returnPressed();
    void on_teMessage_returnWithoutShiftPressed();
    void on_action_Beenden_activated();
    void on_pbSenden_clicked();
    void on_pbLogin_clicked();
    void displayError(QAbstractSocket::SocketError socketError);
    void on_socketDisconnected();
    void on_newGlobalMessage(const QString &sender, const QString &message);
    void on_cSocketError(const QString &error);
    void on_updateFriendlist(QString sFriendlist);
    void on_incommingFriendrequest(QString sFriendrequests);
    void on_changeLoginStatus(int progress, const QString &status);
    void addNewFriend(const QString &friend_loginName, const QString &rMessage);
    void acceptFriendInventation(const quint32 &applicant_uid);
};

#endif // TUNNEL_MAINWINDOW_H
